﻿using FFmpeg.AutoGen;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace FFmpegWinui3.FFmpegSampleFolder
{
    public unsafe class AVIOReading
    {
        public int ReadPack()
        {

            return 0;
        }

        public void Init()
        {
            AVFormatContext* format = null;
            AVIOContext* avio = null;
          
            

            IntPtr avio_ctx_buffer = Marshal.AllocHGlobal(4096);
            var buffer = (byte*)avio_ctx_buffer;
            string url = "";
            ulong* avioBufferSize = (ulong*)4096;
            int error = ffmpeg.av_file_map(url,&buffer, avioBufferSize, 0,null); 
                if (error < 0)
                return;
            format = ffmpeg.avformat_alloc_context();
            if (error < 0)

                return;
            var v  = ffmpeg.av_malloc(4096);
            if (avio == null)
                return;

            //avio = ffmpeg.avio_alloc_context(buffer, 4096, 0, null, &ReadPack, null, null);

            error = ffmpeg.avformat_open_input(&format, null, null, null);
            ffmpeg.avformat_find_stream_info(format, null);
            ffmpeg.av_dump_format(format, 0, url, 0);




        }
    }
}
